	package time.types.query;

/**
 * ...
 * @author waneck
 */

interface Query<A> implements ArrayAccess<A>
{
	function map<B>(fn:A->B):Query<B>;
	function agg<B>(fn:A->Query<B>):Query<B>;
	function distinct():Query<A>;
	
	function filter(fn:A->Bool):Query<A>;
//	function mapFilter<B>(fn:A->Null<B>):Query<B>;
	function sum(?acessor:A->Float):Float;
	function avg(?acessor:A->Float):Float;
	function max(?acessor:A->Float):Float;
	function min(?acessor:A->Float):Float;
	function count():Int;
	function orderBy(?acessor:A->Float, ?asc:Bool = true, ?repeat /* the repeat keyword means that the arguments can be repeated */):Query<A>; //TODO
	function view<Key,Value>(fn:A->{key:Key, value:Value}):DatabaseView<Key, Value>; //TODO
	function exists(fn:A->Bool):Bool;
	function all(fn:A->Bool):Bool;
	function first<A>():A;
	function last<A>():A;
	function get(index:Int) : A;
}

var x 

interface DBView<K, V>
{
	function mapKey<A>(fun:K->A):DBView<A,V>;
	function mapValue<B>(fun:V->B):DBView<K, B>; //etc
}

//como?
//Employee.view().mapKey(self.age).mapValue(self.company); -> Select * from 
//Employee.

interface StringQuery
{
	function like(s:String) : Bool;
	function length():Int;
	//function soundsLike(s:String):Bool;
	//function match(s:String):Bool;
	
}

//other operations possible:
//enumName(x)
//is
//cast()